angular.module("ishop.goodsController", [])
    //选房
    .controller('GoodsAction', function ($scope, $ionicModal, GoodsService) {
        $scope.goodses = GoodsService.all();

        $scope.doGoodsRefresh = function () {//下拉刷新
            var goodses = GoodsService.findGoodses();
            console.log(goodses.length);
            // $scope.$broadcast('event.goodsRefreshed',goodses,1);
            $scope.$broadcast('scroll.refreshComplete');
        };

        $scope.isLoadMore = function () {//滚动scroll是否有分页数据
            return true;
        }

        $scope.loadMore = function () {
            //UNDO 业务逻辑
            $scope.$broadcast('scroll.infiniteScrollComplete');
        }

        //搜索
        $scope.searchSizes = search_size;
        $scope.searchPrices = search_price;
        $scope.searchHouses = search_house;
        $ionicModal.fromTemplateUrl('views/goods/search.html', {
            scope: $scope
        }).then(function (modal) {
            $scope.modal = modal;
        });
        $scope.openSearch = function () {
            $scope.modal.show();
        }
        $scope.closeSearch = function () {
            $scope.modal.hide();
        }
        $scope.searchData = {};
        $scope.doSearch = function () {
            console.log($scope.searchData);
            $scope.modal.hide();
        }


    })
    .controller('GoodsDetailAction', function ($scope, $rootScope, $stateParams, GoodsService) {
        $scope.goods = GoodsService.get($stateParams.id);
        //console.log($scope.goods.images.src);
        $rootScope.buyFooter = false;


        $scope.$on('$ionicView.beforeEnter', function () {
            //$scope.buyFooter = false;
            $rootScope.hideTabs = 'tabs-item-hide';
        });
        $scope.$on('$ionicView.beforeLeave', function () {
            $rootScope.hideTabs = '';
        });




        $scope.goodsScroll = function () {


            $rootScope.buyFooter = true;


        };

    })
;